package com.devshephard.rpcframework.acm.tree.util;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class LC_4 {
    public static void main(String[] args) {

        int[] nums1 = new int[]{};
        int[] nums2 = new int[]{1};

        System.out.println(findMedianSortedArrays(nums1, nums2));

    }


    public static double findMedianSortedArrays(int[] nums1, int[] nums2) {


        List<Integer> list1 = Arrays.stream(nums1).boxed().collect(Collectors.toList());
        List<Integer> list2 = Arrays.stream(nums2).boxed().collect(Collectors.toList());

        list1.addAll(list2);
        list1 = list1.stream().sorted().collect(Collectors.toList());
        return list1.size() % 2 == 0 ? ((list1.get(list1.size()/2) + list1.get(list1.size()/2 - 1)) / 2.0) : list1.get(list1.size()/2);

      /*  nums1.a

        if(nums1.length == 0 && nums2.length == 1){
            return nums2[0];
        }

        if(nums2.length == 0 && nums1.length == 1){
            return nums1[0];
        }

        double m1 = 0;
        double m2 = 0;
        if(nums1.length != 0){
            m1 = nums1.length % 2 == 0 ? (nums1[nums1.length/2] + nums1[(nums1.length/2) - 1]) / 2.0 : nums1[nums1.length/2];
        }

        if(nums2.length != 0) {
            m2 = nums2.length % 2 == 0 ? (nums2[nums2.length / 2] + nums2[(nums2.length / 2) - 1]) / 2.0 : nums2[nums2.length / 2];
        }



        return (m1 + m2) / 2;*/
    }
}
